import axios from 'axios';

const generateImage = async (imageBase64) => {
  try {
    const response = await axios.post('https://api.siliconflow.cn/v1/images/generations', {
      model: 'Kwai-Kolors/Kolors',
      prompt: 'an island near sea, with seagulls, moon shining over the sea, light house, boats int he background, fish flying over the sea',
      negative_prompt: '<string>',
      image_size: '1024x1024',
      batch_size: 1,
      seed: 4999999999,
      num_inference_steps: 20,
      guidance_scale: 7.5,
      image: imageBase64
    }, {
      headers: {
        Authorization: 'Bearer '+process.env.VUE_APP_API_KEY,
        'Content-Type': 'application/json'
      }
    });
    console.log(response.data);
    return response.data;
  } catch (error) {
    console.error(error);
    return {}
  }
};

const reqllm = async (ingredients) => {
    try {
const response = await axios.post('https://api.siliconflow.cn/v1/chat/completions', {
    model: 'Qwen/QwQ-32B',
    messages: [{
      role: 'user',
      content: `根据以下食材生成一个三明治食谱: ${ingredients}`
    }],
    stream: false,
    max_tokens: 512,
    temperature: 0.7
  }, {
    headers: {
      Authorization: 'Bearer ' + process.env.VUE_APP_API_KEY,
      'Content-Type': 'application/json'
    }
  }); 
  console.log(response.data);
  return response.data;
} catch (error) {
    console.error(error);
    return {}
  }
};


export default { generateImage ,reqllm};